import axios from "axios";

let serverUrl = process.env.BACK_SERVER_URL;
if (!serverUrl) {
  console.log(
    "back server url not set environment use default http://127.0.0.1:3001",
  );
} else {
  serverUrl = "http://127.0.0.1:3001";
}

export const getVerificationTokenByEmail = async (email: string) => {
  const user = await axios
    .get(`${serverUrl}/user/token/${email}`)
    .then((response) => {
      return response.data; // The response data
    })
    .catch((error) => {
      console.error("Error fetching data:", error);
      return null;
    });
  return user;
};
export const deleteVerificationTokenByEmail = async (email: string) => {
  const user = await axios
    .get(`${serverUrl}/user/token/delete/${email}`)
    .then((response) => {
      return response.data; // The response data
    })
    .catch((error) => {
      console.error("Error fetching data:", error);
      return null;
    });
  return user;
};

//export const getVerificationTokenByToken = async (token: string) => {};
